﻿using hCommand;
using System;

namespace Persistence {
    public class DooDeleteDetailEngine : GkTransaction
    {
        public WhDooDet wdd;
        protected override TransRes Execute()
        {
            try
            {
                WhDoo doo =getById<WhDoo>(wdd.pid);
                var count = queryUnique<int>($"select count(*) from wh_doo_det  where pid={doo.id}");
                if (count == 0)
                {
                    doo.status = (int)StockStatus.编辑;
                    update(doo,x=>x.status);
                }
                if (wdd.finshCount == 0 && wdd.activeCount == 0)
                {
                 delete(wdd);
                }
            }
            catch (Exception e)
            {
                return new TransRes(e.Message);
            }
            return new TransRes();
        }
    }
}
